home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
stdio
/
c
/
rename
< prev
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
52 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/stdio/c/RCS/rename,v $
* $Date: 1996/05/06 09:01:34 $
* $Revision: 1.2 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: rename,v $
* Revision 1.2 1996/05/06 09:01:34 unixlib
* Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
* Saved for 3.7a release.
*
* Revision 1.1 1996/04/19 21:32:42 simon
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: rename,v 1.2 1996/05/06 09:01:34 unixlib Rel $";
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
__STDIOLIB__
int
rename (const char *old, const char *new)
{
{
register const char *s1 = old, *s2 = new;
register int c1, c2;
while (c1 = *s1++, c2 = *s2++)
{
if (isupper (c1))
c1 = _tolower (c1);
if (isupper (c2))
c2 = _tolower (c2);
if (c1 != c2)
break;
}
if (c1 != c2)
unlink ((char *) new);
}
if (link ((char *) old, (char *) new))
return (-1);
return (0);
}